-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(WIP) feat: LWE #177
base: main
Are you sure you want to change the base?
(WIP) feat: LWE #177
Conversation
I can't replicate the failing test locally. Maybe an issue with toolchain? |
Maybe rerun the tests, |
It's so odd. Drives me kinda crazy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Would love to see it work for larger messages!
let dist_to_q_half = if result >= q_half { | ||
// If result ≥ q/2, distance is min(result - q/2, q - result + q/2) | ||
(result - q_half).min(-result + q_half) | ||
} else { | ||
// If result < q/2, distance is min(q/2 - result, result + q/2) | ||
(q_half - result).min(result + q_half) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed?
I think (result - q_half) <= (-result + q_half)
for result >= q_half
, and (q_half - result) <= (result + q_half)
for result < q_half
, is always true. I also did a quick check if this is ever not true for test_encryption_decryption
.
Maybe you could verify this?
Maybe this could be distilled to:
let dist_to_q_half = if result >= q_half { | |
// If result ≥ q/2, distance is min(result - q/2, q - result + q/2) | |
(result - q_half).min(-result + q_half) | |
} else { | |
// If result < q/2, distance is min(q/2 - result, result + q/2) | |
(q_half - result).min(result + q_half) | |
}; | |
let dist_to_q_half = (result - q_half).min(q_half - result); |
WIP
Plaintext
?)